﻿using UnityEngine;

namespace FastDev
{
    public abstract class GoapAction : IGoapAction
    {
        public abstract string Name { get; protected set; }

        public abstract int Cost { get; protected set; }

        public abstract GoapState PreCondition { get; protected set; }

        public abstract GoapState Effect { get; protected set; }

        public abstract GoapAgent Agent { get; protected set; }

        public GoapActionState GoapActionState { get; protected set; }

        public float Progress { get; protected set; }

        public GoapAction(GoapAgent goapAgent)
        {
            this.Agent = goapAgent;
            GoapActionState = GoapActionState.None;
        }

        public virtual void OnReset()
        {
            Debug.Log(Name + " OnReset");

            GoapActionState = GoapActionState.None;
        }

        public virtual void OnStart()
        {
            Debug.Log(Name + " OnStart");
            GoapActionState = GoapActionState.OnStart;
        }

        public virtual void OnDone()
        {
            Debug.Log(Name + " OnDone");
            GoapActionState = GoapActionState.OnDone;
        }

        public virtual void OnUpdate()
        {
            GoapActionState = GoapActionState.OnUpdate;
        }

        public virtual void OnFailed()
        {
            Debug.LogError(Name + " OnFailed");
            GoapActionState = GoapActionState.OnFailed;
        }
    }
}
